<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>

    <script src="./js/vue.js"></script>
    <script>
      const MyButton = {
        template: `<button @click="count++">当前被点击了{{this.count}}次</button>`,
        data() {
          return {
            count: 0,
          };
        },
      };

      const Title = {
        props: {
          title: String,
        },
        template: `<h1>{{ this.title }}</h1>`,
      };

      // 全局注册
      // Vue.component("MyButton", MyButton);

      const vm = new Vue({
        template: `<div>
          <MyButton />
          <MyButton />
          <MyButton />
          <my-button/>
          <Title title="一级标题"/>
          <Title title="二级标题"/>
        </div`,
        components: {
          MyButton,
          Title,
        },
      });

      vm.$mount("#app");

      console.log("first");
    </script>
  </body>
</html>
